package com.magical.entity;

import java.text.NumberFormat;

public class User {
    private Integer id;

    private String passwd;

    private String nickname;

    private String headurl;

    private String email;

    private Integer authorityId;

    private Integer gradeId;
    private Integer usedSpace;
    private Integer ifVerified;
    private String code;

    public String getUserUsedSpace() {
        int type=0;
        double size=usedSpace;
        while(size>=1024){
            size/=1024.0;
            type++;
        }
        NumberFormat format=NumberFormat.getNumberInstance() ;
        format.setMaximumFractionDigits(1);
        userUsedSpace = format.format(size);
        switch (type){
            case 1:
                userUsedSpace +="\tKB";break;
            case 2:
                userUsedSpace +="\tMB";break;
            case 3:
                userUsedSpace +="\tGB";break;
            case 4:
                userUsedSpace +="\tTB";break;
            default:
                userUsedSpace +="\tB";
        }
        return userUsedSpace;
    }

    public void setUserUsedSpace(String userUserdSpace) {
        this.userUsedSpace = userUserdSpace;
    }

    private String userUsedSpace;

    private Authority authority;
    private Grade grade;


    public Integer getIfVerified() {
        return ifVerified;
    }

    public void setIfVerified(Integer ifVerified) {
        this.ifVerified = ifVerified;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getHeadurl() {
        return headurl;
    }

    public void setHeadurl(String headurl) {
        this.headurl = headurl;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getAuthorityId() {
        return authorityId;
    }

    public void setAuthorityId(Integer authorityId) {
        this.authorityId = authorityId;
    }

    public Integer getGradeId() {
        return gradeId;
    }

    public void setGradeId(Integer gradeId) {
        this.gradeId = gradeId;
    }

    public Authority getAuthority() {
        return authority;
    }

    public void setAuthority(Authority authority) {
        this.authority = authority;
    }

    public Grade getGrade() {
        return grade;
    }

    public void setGrade(Grade grade) {
        this.grade = grade;
    }

    public Integer getUsedSpace() {
        return usedSpace;
    }

    public void setUsedSpace(Integer usedSpace) {
        this.usedSpace = usedSpace;
    }
}

